//
//  MZWeizhiViewController.m
//  民族文化宫
//
//  Created by kobehjk on 14-8-9.
//  Copyright (c) 2014年 WANG CUNRUI. All rights reserved.
//

#import "MZWeizhiViewController.h"

@interface MZWeizhiViewController ()
@property (strong,nonatomic) UIScrollView *scrollView;
@property (strong,nonatomic) UIImageView *imageView;
@property (strong,nonatomic) UILabel *label;
@property (strong,nonatomic) UIImageView *imageView1;
@property (nonatomic) CGPoint labelframe;
@end

@implementation MZWeizhiViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    CGRect frame = self.view.bounds;
    CGSize f = frame.size;
    CGFloat h = f.height;
    CGFloat w = f.width;
    [self chuanzuobiao:_MZID];
    _labelframe = [self chuanzuobiao:_MZID];
    float a = _labelframe.x;
    float b = _labelframe.y;
    _scrollView =[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,w+400,h)];
    _scrollView.contentSize=CGSizeMake(870,568);
    _scrollView.backgroundColor=[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1.0];
    _scrollView.pagingEnabled=YES;
    [self.view addSubview:_scrollView];
    self.imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"imm_01.jpg"]];
    self.imageView.frame  = CGRectMake(0, 0, w+200, 0.8*h);
    [self.scrollView addSubview:self.imageView];
    _label = [[UILabel alloc] initWithFrame:CGRectMake( a, b+20, 30, 20)];
    [_label setNumberOfLines:0];
    _label.lineBreakMode = NSLineBreakByWordWrapping;
    NSString *s1 = [NSString stringWithFormat:@"%@",_MZID];
    _label.text = s1;
    _label.textColor = [UIColor redColor];
    UIFont *font = [UIFont boldSystemFontOfSize:15];
    _label.font = font;
    CGSize size1 = CGSizeMake(320,500);
    NSDictionary *attribute1 = @{NSFontAttributeName: _label.font};
    CGSize labelsize = [_label.text boundingRectWithSize:size1 options: NSStringDrawingTruncatesLastVisibleLine |NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute1 context:nil].size;
    _label.frame = CGRectMake(a,b+20, labelsize.width, labelsize.height);
    _label.layer.borderWidth = 1;
    _label.layer.borderColor = [[UIColor redColor] CGColor];
    _label.layer.cornerRadius = 4;
    [_imageView addSubview:_label];
    self.imageView1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"07-map-marker.png"]];
    self.imageView1.frame  = CGRectMake(a, b, 15, 17);
    [self.scrollView addSubview:self.imageView1];
    NSLog(@"maid = %@",_MZID);
    // Do any additional setup after loading the view.
}

- (CGPoint)chuanzuobiao:(NSString *)point
{
    
    CGFloat x = 0;
    CGFloat y = 0;
    if ([_MZID isEqualToString:@"少数民族非物质文化遗产展示周"]) {
        CGFloat x = 80;
        CGFloat y = 80;
        return CGPointMake(x,y);
    }
    else if ([_MZID isEqualToString:@"宫藏文物精华展"])
    {
        CGFloat x = 128;
        CGFloat y = 120;
        return CGPointMake(x,y);
    }
    else if ([_MZID isEqualToString:@"2014年古代精品面具展"])
    {
        CGFloat x = 50;
        CGFloat y = 60;
        return CGPointMake(x,y);
    }
    else if ([_MZID isEqualToString:@"党的群众路线档案展览"])
    {
        CGFloat x = 110;
        CGFloat y = 120;
        return CGPointMake(x,y);
    }
    else if ([_MZID isEqualToString:@"少数民族地区民族服饰展"])
    {
        CGFloat x = 40;
        CGFloat y = 100;
        return CGPointMake(x,y);
    }
    else if ([_MZID isEqualToString:@"国家古代“钱币”巡展"])
    {
        CGFloat x = 70;
        CGFloat y = 140;
        return CGPointMake(x,y);
    }
    else if ([_MZID isEqualToString:@"2014年《中华玉器展》"])
    {
        CGFloat x = 110;
        CGFloat y = 120;
        return CGPointMake(x,y);
    }
    ;

    return CGPointMake(x,y);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
